using MidnightPeach.Engine.Packages;
using MidnightPeach.Engine.Schema;
using MidnightPeach.Engine.Schema.DataSchema;

namespace MidnightPeach.Engine.Generators.DataGenerators
{
    internal class ColumnGenerator : DataGenerator
    {
        private readonly Column _column;

        public ColumnGenerator(Package package, Column column) : base(package)
        {
            _column = column;
        }

        internal override string Generate(Macro macro, string text)
        {
            switch (macro.Value)
            {
                case "Name":
                    return _column.Name;

                case "PascalName":
                    return _column.PascalName;

                case "CamelName":
                    return _column.CamelName;

                case "Type":
                    return _column.Type;

                case "BeginCommentIfReadOnly":
                    return _column.ReadOnly ? "/* not available for ReadOnly column" : string.Empty;

                case "EndCommentIfReadOnly":
                    return _column.ReadOnly ? "*/" : string.Empty;

                case "NonNullableType":
                    return _column.NonNullableType;

                case "Identifier":
                    return _column.Identifier;

                default:
                    throw new UnsupportedMacroException(macro, text, this);
            }
        }
    }
}